package com.example.xm.controller;

import com.example.xm.entity.Xuanchuan;
import com.example.xm.entity.XuanchuanItem;
import com.example.xm.service.IXuanchuanItemService;
import com.example.xm.service.IXuanchuanService;
import com.example.xm.web.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/xuanchuanitem")
public class XuanchuanItemController {
    @Autowired
    IXuanchuanItemService shipinfenleiService;
    @PostMapping("/add")
    public Result reg(@RequestBody XuanchuanItem gonggao){
        XuanchuanItem reg = shipinfenleiService.reg(gonggao);
        reg.setList(new ArrayList<>());
        return Result.success(reg);
    }

    @DeleteMapping("/delete/{ids}")
    public Result delete(@PathVariable String ids){
        String[] split = ids.split(",");
        int[] intArray = new int[split.length];
        for (int i = 0; i < split.length; i++) {
            intArray[i] = Integer.parseInt(split[i]);
        }
        shipinfenleiService.delete(intArray);
        return Result.success();
    }
}
